<?php
namespace Home\Controller;

use Think\Controller;

class ChaxunController extends Controller 
{
  public function index()
  {
  	if(IS_POST)
  	{
  		$pid = I('post.county');
		  $zhen = M('ct')->where("pid='%s'",$pid)->group("zhen")->select();
  	}
  	$this->assign('zhen',$zhen);
    $this->display();
  }
  public function xs($zhen)
  {
    $p = I('p')?I('p'):1;
    $a = ($p-1)*5;
    $xs = M('ct')->field('zhen,an,xiao,lin,jia,ph,fei')->where("zhen='%s'",$zhen)->limit($a,5)->select();
    // 查询满足要求的总记录数
    $count  = M("ct")->where("zhen='%s'",$zhen)->count();
    //echo M()->getLastSql();die;
    // 实例化分页类 传入总记录数和每页显示的记录数
    $Page = new \Think\Page($count,5);
    $show = $Page->show();// 分页显示输出

    $this->assign('page',$show);
    $this->assign('xs',$xs);
    $this->display();
  }
}